package com.Java.train.business.controller;

import com.Java.train.common.response.CommonResp;
import com.Java.train.business.entity.DTO.TrainStationDTO;
import com.Java.train.business.req.TrainStationQueryReq;
import com.Java.train.common.response.PageResp;
import com.Java.train.business.entity.TrainStation;
import com.Java.train.business.service.TrainStationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;

/**
* @author luomoxingchen
* @since 2024-09-22
*/
@RestController
@RequestMapping("/admin/train-station")
public class TrainStationController {

    @Autowired
    private TrainStationService trainStationService;


    @GetMapping("/query-list")
    @ApiOperation("TrainStation查询全部")
    public CommonResp< PageResp<TrainStationDTO>> queryList(@Valid TrainStationQueryReq trainStationQueryReq){
        PageResp<TrainStationDTO> list = trainStationService.queryList(trainStationQueryReq);
        return new CommonResp<>(list);
    }

    @PostMapping("/save")
    @ApiOperation("TrainStation修改")
    public CommonResp<Object> update(@Valid @RequestBody TrainStation trainStation) {
        return trainStationService.modify(trainStation);
    }


    @DeleteMapping(value = "/delete/{ids}")
    @ApiOperation("TrainStation删除(单个条目)")
    public CommonResp<Object> remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        return trainStationService.remove(ids);
    }
}
